package com.bstek.common.config;

import com.bstek.common.properties.ReportDatabaseProperties;
import com.bstek.common.properties.ReportProperties;
import com.bstek.report.provider.DatabaseProvider;
import com.bstek.report.service.IReportFileService;
import com.bstek.ureport.provider.report.ReportProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties({ReportProperties.class, ReportDatabaseProperties.class})
public class ReportConfigration {

    @Bean
    @ConditionalOnMissingBean
    public ReportProvider reportProvider(ReportDatabaseProperties properties, IReportFileService service) {
        return new DatabaseProvider(properties, service);
    }
}
